from concepts import *

from .city import City
from .map import Map


class Scenario(Object):
    name      =_ (None)
    size      =_ (None)
    gameset   =_ (None)
    geography =_ (None)
    
    properties = Attribute(initial = {}, convert = dict, transform = dict)
    
    @property
    @memoized
    def city(self):
        return City(self.name, self.map, self.gameset.calendar())
    
    @property
    @memoized
    def map(self):
        return Map(self.width, self.height, self.geography)
    
    @property
    def width(self):
        return self.size
    
    @property
    def height(self):
        return self.size
    
    def place_from(self, function):
        for buildings in function(self.city.map.at):
            for building in buildings:
                building.realize()
